// Reading a text-file one character at a time using read( ) mathod of input stream
import java.io.*;

public class FileReadChar2{
  public static void main(String[] args) throws IOException{
    FileInputStream fis = new FileInputStream("input.txt");
    FileOutputStream fos = new FileOutputStream("output2.txt");
    PrintWriter pwriter = new PrintWriter(fos);
    
    int unicode, count = 0;
    char ch;
    while((unicode = fis.read()) != -1){
       ch = (char) unicode;     
       if(Character.isLowerCase(ch)){
           count++;
           ch = Character.toUpperCase(ch);
       }
       
       pwriter.print(ch);
    } 
    
    fis.close();
    pwriter.close();
    System.out.printf("The number of lowercase letters in input.txt is %d%n", count);
    System.out.println("The file output2.txt has been created . . . ");
  }
}

